package com.qt.thread;

import java.util.concurrent.Callable;

/**
 * @Author zsf
 * @Date 2023/10/3 1:38
 * @Version 1.0
 */
public class MyCallableTicket  implements Runnable {
    int ticket = 0;

    @Override
    public void run() {
        while (true) {
            synchronized (this) {
                if (ticket < 100) {
                    try {
                        Thread.sleep(10);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println(Thread.currentThread().getName() + ": 票号：" + ticket);
                    ticket++;
                } else {
                    break;
                }
            }
        }
    }


}
